//============================================================================
// Name        : MeetSerie.cpp
// Author      : Patrick van ieperen
// Version     : 0.0
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include "EnhMeetserie.h"
#include "Meetserie.h"
#include <iostream>
using namespace std;



void showMenu( void );

int main()
{
	string name = "";
	bool quit = false;
	int choice =0;
	int value,cnt;
	int number = 0;
	
	// aanmaken van een object van de Enhanched meet serie.
    EnhMeetserie m("demo");
    
    while (!quit)
	{
		showMenu();
		
        cin >> choice;
        cin.ignore();
        
        switch (choice)
        {
			case 1:
				number = 0;
				m.bepAantalMeetwaarden(number);
				for ( int i = 0; i< number; i++)
				{
					cout << "On position : " << i << " is value : " << m.getMeetwaarde(i) << endl;
				}
				if (number == 0) 
				{
					cout << "The series is empty " << endl;
				}
			break;
			
			case 2:
				number =0;
				cout << "give the value that you want to add to the serie : ";
				cin >> number;
				cin.ignore();
				
				if (!(m.isVol()))
				{
					m.voegToe(number);
				}
				else
				{
					cout << " The array is full, it's not possible to add more measurments" << endl;
				}
			break;
			
			case 3:
				cout << " It is"  << (m.isVol() ? " not possible" : " possible")  << " to add a new measurement"  << endl;
			break;
			
			case 4:
				number = 0;
				cnt = 0;
				m.bepAantalMeetwaarden(number);
				cout << " What number you want to check : " ;
				cin >> value;
				cin.ignore();
				
				for ( int i=0; i < number; i++)
				{
					if (value == m.getMeetwaarde(i))
					{
						cnt++;
					}
				}
				cout << " The number " << value << " is used "  << cnt << " times in the series" << endl;
				
			break;
			
			case 5:
				cout << " De name of this series is : " << m.getNaam() << endl;
			break;
			
			case 6:
				cout << " What is the new name of the measument serie : ";
				getline(cin,name);
				
				m.setNaam(name);
			break;
			
			case 7:
				cout << " What number you want to check : " ;
				cin >> number;
				cin.ignore();
				cout << " the number " << number << (m.meetwaardeKomtVoor(number) ? " is" : " is not" ) << " in the list" << endl;
			break;
			
			case 8:
			{	//met de brackets maak je een  block. Dit voorkomt crosses  initialization
				Meetserie m1("m1"); 
				m1.voegToe(8);
				m1.voegToe(9);
				m.voegToeMeetserie(&m1);
			}
			break;
			
			case 9:
			{
				EnhMeetserie mx1("mx1");
				mx1.voegToe(-2);
				mx1.voegToe(-3);
				m.voegToeMeetserie(&mx1);
			}
				
			break;
			
			case 10:
				cout << " number of different values " << m.getAantalVerschillendeWaarden()  << endl;
			break;
			
			case 11:
				quit=true;
				break;
				
			default:
				cout << " i got confused from your input" << endl;	
		}
     }

    return 0;
}
void showMenu( void )
{
	
	cout << ("\nMeasurement series menu");
	cout << ("\n===========================");
	cout << ("\n[1]  Show all values");
	cout << ("\n[2]  Add a measurement value");
	cout << ("\n[3]  Test is an other value can be added");
	cout << ("\n[4]  Show how often a certain value is stored");
	cout << ("\n[5]  show the measurement serie's name");
	cout << ("\n[6]  Change the measurement serie's name");
	cout << ("\n[7]  Test if a certain value is already stored");
	cout << ("\n[8]  Add measurement series m1 with values 8 and 9");
	cout << ("\n[9]  Add enhanced measurment series mx1 with values -2 and -3");
	cout << ("\n[10] Show the number of different values");
	cout << ("\n[11] Quit.");
	cout <<  ("\n\nChoice : ");
}
